#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <unistd.h>
#include <vector>
#include <pthread.h>
#include "mutex.hpp"

class cond
{
public:
    cond() { pthread_cond_init(&_cond, nullptr); }
     
void Wait(mutex &mx)
{
int n = pthread_cond_wait(&_cond, mx.getmutex());
(void)n;
}
    void notify()
    {
        int n = pthread_cond_signal(&_cond);
        (void)n;
    }
    void allnotify()
    {
        int n = pthread_cond_broadcast(&_cond);
        (void)n;
    }
    ~cond() { pthread_cond_destroy(&_cond); }

private:
    pthread_cond_t _cond;
};